package com.ebt.m.customer.item;

import com.ebt.m.customer.listener.IContactComparable;
import com.ebt.m.customer.listener.ICustomer;
import com.ebt.m.customer.util.PinyinUtil;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;

public class Contact implements Serializable, ICustomer, IContactComparable{

	public static final String DEFAULT_DESCRIPTION = "\u5176\u5b83";//"其它";
	
	public static HashMap<String, String> phoneDescription;
	public static HashMap<String, String> emailDescription;
	public static HashMap<String, String> imDescription;
	
	static{
		phoneDescription = new HashMap<String, String>();
		phoneDescription.put("1", "\u5bb6\u5ead");//家庭
		phoneDescription.put("2", "\u624b\u673a");//手机
		phoneDescription.put("3", "\u5de5\u4f5c");//工作
		phoneDescription.put("4", "\u5de5\u4f5c\u4f20\u771f");//工作传真
		phoneDescription.put("5", "\u5bb6\u5ead\u4f20\u771f");//家庭传真
		
		emailDescription = new HashMap<String, String>();
		emailDescription.put("1", "\u5bb6\u5ead");//家庭
		emailDescription.put("2", "\u5de5\u4f5c");//工作
		emailDescription.put("3", "\u5176\u5b83");//"其它";
		
		imDescription = new HashMap<String, String>();
		imDescription.put("1", "msn");
		imDescription.put("2", "yahoo");
		imDescription.put("3", "skype");
		imDescription.put("4", "qq");
		imDescription.put("5", "gtalk");
		imDescription.put("6", "icq");
		imDescription.put("7", "jabber");
		
	}
	
	//联系人姓名，对应于ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME
	public String name;

	public char sortKeyChar;//显示的sortkey  如 "A" "B" "#"
	
	//联系人排序名称，对应于ContactsContract.CommonDataKinds.Phone.SORT_KEY_PRIMARY
	public String sortKeyString;
	
	//联系人rawContactId，对应于ContactsContract.CommonDataKinds.Phone.RAW_CONTACT_ID
	public String rawContactId;
	
	public boolean hasImported;

    public boolean hasIgnored;
	//联系人被导入后，首先生成新的customer，新的customer生成后返回的customeruuid赋值给此参数，
	public String customerUuid;
	//联系人被导入后，记录导入的时间
	public Long lastActiveTime;

	//通讯录中的此记录是否时ignore的，此项用于在“获客”时进行判断此条记录是否需要删除掉
//	public Long contactIgnore;

	public String remarkUuid;

    public String customerFromContactUuid;

	public ArrayList<CommonContact> commonContacts = new ArrayList();
	
	public boolean addCommonContacts(ArrayList<CommonContact> commonContacts){
		return this.commonContacts.addAll(commonContacts);
	}
	
	public boolean addCommonContact(CommonContact commonContact){
		return this.commonContacts.add(commonContact);
	}
	
	public static class CommonContact{
		
		public String value;
		public String classification;
		public int type;
		public String description;
		
		public CommonContact(String value, String classification, int type, String description){
			this.value = value;
			this.classification = classification;
			this.type = type;
			this.description = description;
		}
	}
	
	public Contact(){
	}
	
	public Contact(String name, String rawContactId, boolean hasImported) {
		this.name = name;
		this.sortKeyString = PinyinUtil.generateDisplayStringSingle(name);
		this.sortKeyChar = PinyinUtil.getSortKeyChar(sortKeyString);
		this.rawContactId = rawContactId;
		this.hasImported = hasImported;
	}
	
	public boolean isHasImported() {
		return hasImported;
	}

	public void setHasImported(boolean hasImported) {
		this.hasImported = hasImported;
	}

	public String getRawContactId() {
		return rawContactId;
	}

	public void setRawContactId(String rawContactId) {
		this.rawContactId = rawContactId;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public char getSortKeyChar() {
		return sortKeyChar;
	}

	public void setSortKeyChar(char sortKeyChar) {
		this.sortKeyChar = sortKeyChar;
	}

	public String getSortKeyString() {
		return sortKeyString;
	}

	public void setSortKeyString(String sortKeyString) {
		this.sortKeyString = sortKeyString;
	}
	
	@Override
	public String toString() {

		String s  =  "[ name is " + name + " | sortKeyChar is " + String.valueOf(sortKeyChar)
				+ " | sortKeyString is " + sortKeyString + " | rawContactId is " + rawContactId 
				+ " | hasImported is " + hasImported + " | customerUuid is " + customerUuid + " ]";

		return s;
	}

	@Override
	public String getCustomerUuid() {
		return customerUuid;
	}

	@Override
	public String getSortKey() {
		return sortKeyString;
	}

    public void setCustomerUuid(String customerUuid){
        this.customerUuid = customerUuid;
    }

}
